
<%@page import="com.liferay.portal.kernel.util.Constants"%>
<%@page import="qldc.pm.qlktcsdldc.actions.ActionHandlerConstant"%>
<%@page import="qldc.pm.qlktcsdldc.service.DanhMucSoBanNganhLocalServiceUtil"%>
<%@ include file="../init.jsp"%>
<%
		String redirectURL = ParamUtil.getString(request, "redirect");
		PortletURL backURL = renderResponse.createRenderURL();
		backURL.setParameter("mvcPath", "/html/qlktcsdldc/danh_muc_so_ban_nganh.jsp");
		backURL.setParameter("tabs1", QLKTCSDLDCContants.PAGEID_DMSBN_MAN_HINH_CHINH);
		backURL.setParameter("redirect", redirectURL);
		
		PortletURL addURL = renderResponse.createRenderURL();
		addURL.setParameter("mvcPath", "/html/qlktcsdldc/danh_muc_so_ban_nganh.jsp");
		addURL.setParameter("tabs1", QLKTCSDLDCContants.PAGEID_DMSBN_THEM_MOI_SO_BAN_NGANH);
		addURL.setParameter("redirect", redirectURL);
%>
<%-- <portlet:renderURL var="addSoBanNganhURL">
	<portlet:param name="mvcPath" value="/html/qlktcsdldc/danh_muc_so_ban_nganh.jsp"/>
	<portlet:param name="tabs1" value="<%=QLKTCSDLDCContants.PAGEID_DMSBN_THEM_MOI_SO_BAN_NGANH %>" />
</portlet:renderURL> --%>
<portlet:actionURL var="DMSBN_ManHinhChinhURL">
	<portlet:param name="<%=ActionHandlerConstant.ACTION_HANDLER_PARAM%>" value="<%=ActionHandlerConstant.DANH_MUC_SO_BAN_NGANH_ACTION%>" />
	<portlet:param name="<%=Constants.ACTION%>" value="DMSBN_ManHinhChinhAction" />
	<portlet:param name="redirect" value="<%=backURL.toString()%>" />
	<portlet:param name="addRedirect" value="<%=addURL.toString()%>" />
</portlet:actionURL>
<h2 class="tle-Content">
	<liferay-ui:message key="so-ban-nganh" />
</h2>
<div class="main-Content">
	<form method="POST" target="_blank" action="<%=DMSBN_ManHinhChinhURL.toString() %>" name="<portlet:namespace/>fmDMSBN_ManHinhChinh" id="<portlet:namespace/>fmDMSBN_ManHinhChinh">
		<aui:input name="<%= Constants.CMD %>" type="hidden" />
		<%
			String tenSoBanNganh = ParamUtil.getString(request, "tenSoBanNganh");
		%>
		<table class="gridnormal">
			<tr>
				<td>
					<liferay-ui:message key="ten-so-ban-nganh" />
				</td>
				
				<td>
					<input type="text" name="<portlet:namespace/>tenSoBanNganh" 
							id="<portlet:namespace/>tenSoBanNganh" value="<%= Validator.isNotNull(tenSoBanNganh) ? tenSoBanNganh :"" %>" />
				</td>
				<td colspan="2">
					<input type="button" class="" onclick="soBanNganhTimKiem()" value="<liferay-ui:message key="tim-kiem" />" id="<portlet:namespace/>timKiem" /> 
					<input type="button" class="" onclick="soBanNganhThemMoi()" value="<liferay-ui:message key="them-moi" />"  id="<portlet:namespace/>themMoi" />
					<input type="button" class="" onclick="soBanNganhIn()" value="<liferay-ui:message key="in" />"  id="<portlet:namespace/>in" />
				</td>				
			</tr>
		</table>
		<liferay-ui:search-container emptyResultsMessage="no-web-content-were-found" >
			<liferay-ui:search-container-results>
				<%
					results = DanhMucSoBanNganhLocalServiceUtil.searchByTenSoBanNganh(tenSoBanNganh);
					if(Validator.isNotNull(results)){
						total = results.size();
					}else{
						total = 0;
					}
					pageContext.setAttribute("results", results);
					pageContext.setAttribute("total", total);
				%>
			</liferay-ui:search-container-results>
			<%
				int start = 0;
			%>
			<liferay-ui:search-container-row className="qldc.pm.qlktcsdldc.model.DanhMucSoBanNganh" keyProperty="IDQLKT_DanhMucSoBanNganh" modelVar="soBanNganh">
				<liferay-ui:search-container-column-text cssClass="aui-w3" name='STT' value="<%=String.valueOf(++start)%>" />
				<liferay-ui:search-container-column-text cssClass="aui-w10" name='<%=LanguageUtil.get(request.getLocale(), "ten-so-ban-nganh")%>' value="<%= soBanNganh.getTenSoBanNganh()%>" />
				<liferay-ui:search-container-column-text cssClass="aui-w15 txt-center" name='<%=LanguageUtil.get(request.getLocale(), "dia-chi")%>' value="<%= soBanNganh.getDiaChi()%>" />
				<liferay-ui:search-container-column-text cssClass="aui-w10 txt-center" name='<%=LanguageUtil.get(request.getLocale(), "so-dien-thoai")%>' value="<%= soBanNganh.getSoDienThoai() %>" />
				<liferay-ui:search-container-column-text cssClass="aui-w20 txt-center" name='<%=LanguageUtil.get(request.getLocale(), "fax")%>' value="<%= soBanNganh.getFax()%>" />
				<liferay-ui:search-container-column-text cssClass="aui-w10 txt-center" name='<%=LanguageUtil.get(request.getLocale(),"email")%>' value="<%= soBanNganh.getEmail()%>" />
				<liferay-ui:search-container-column-text cssClass="aui-w10 txt-center" name='<%=LanguageUtil.get(request.getLocale(),"website")%>' value="<%= soBanNganh.getWebsite()%>" />
				<liferay-ui:search-container-column-text cssClass="aui-w10 txt-center" name='<%=LanguageUtil.get(request.getLocale(),"nguoi-lien-he")%>' value="<%= soBanNganh.getNguoiLienHe()%>" />
				
				<liferay-ui:search-container-column-text cssClass="aui-Action aui-w10 txt-center" align="right">
					<liferay-ui:icon-menu message="thao-tac">
						 <portlet:renderURL var="suaURL">
							<portlet:param name="mvcPath" value="/html/qlktcsdldc/danh_muc_so_ban_nganh.jsp"/>
							<portlet:param name="soBanNganhId" value="<%= String.valueOf(soBanNganh.getIDQLKT_DanhMucSoBanNganh()) %>" />
							<portlet:param name="tabs1" value="<%=QLKTCSDLDCContants.PAGEID_DMSBN_SUA_SO_BAN_NGANH %>" />
						</portlet:renderURL>
						<liferay-ui:icon image="edit" message="sua" url="<%= suaURL.toString() %>" />
						
						<portlet:renderURL var="phanQuyenURL">
							<portlet:param name="mvcPath" value="/html/qlktcsdldc/danh_muc_so_ban_nganh.jsp"/>
							<portlet:param name="soBanNganhId" value="<%= String.valueOf(soBanNganh.getIDQLKT_DanhMucSoBanNganh()) %>" />
							<portlet:param name="tabs1" value="<%=QLKTCSDLDCContants.PAGEID_DMSBN_PHAN_QUYEN_THAO_TAC %>" />
						</portlet:renderURL>
						<liferay-ui:icon image="edit" message="phan-quyen-xu-ly-truong-dl-cong-dan" url="<%= phanQuyenURL.toString() %>" />
						
						<%
							PortletURL url = renderResponse.createRenderURL();
							url.setParameter("mvcPath", "/html/qlktcsdldc/danh_muc_so_ban_nganh.jsp");
							url.setParameter("tabs1", QLKTCSDLDCContants.PAGEID_DMSBN_MAN_HINH_CHINH);
						%>						
						<portlet:actionURL var="deleteSoBanNganhURL" >
							<portlet:param name="redirect"  value="<%= url.toString() %>" />
							<portlet:param name="<%=ActionHandlerConstant.ACTION_HANDLER_PARAM%>" value="<%=ActionHandlerConstant.DANH_MUC_SO_BAN_NGANH_ACTION%>" />
							<portlet:param name="<%=Constants.ACTION%>" value="deleteSoBanNganh" />
							<portlet:param name="soBanNganhId" value="<%= String.valueOf(soBanNganh.getIDQLKT_DanhMucSoBanNganh()) %>" />
						</portlet:actionURL>
						<liferay-ui:icon-delete message="xoa" url="<%= deleteSoBanNganhURL.toString() %>" />
					</liferay-ui:icon-menu>
				</liferay-ui:search-container-column-text> 
			</liferay-ui:search-container-row>
			<liferay-ui:search-iterator searchContainer="<%=searchContainer%>" />

		</liferay-ui:search-container>
		
	</form>
</div>


<script type="text/javascript">
function soBanNganhTimKiem(){
	console.log('soBanNganhTimKiem');
	$('#<portlet:namespace/>fmDMSBN_ManHinhChinh').removeAttr("target");
	$('#<portlet:namespace/>fmDMSBN_ManHinhChinh').removeAttr("action");
	$('#<portlet:namespace/>cmd').val('<%=QLKTCSDLDCContants.TIM%>');
	$("#<portlet:namespace/>fmDMSBN_ManHinhChinh").attr('onsubmit', 'return true;');
	$("#<portlet:namespace/>fmDMSBN_ManHinhChinh").submit();
	
};
function soBanNganhThemMoi(){
	console.log('quanLyTaiKhoanAdd');
	$('#<portlet:namespace/>fmDMSBN_ManHinhChinh').removeAttr("target");
	$('#<portlet:namespace/>cmd').val('<%=QLKTCSDLDCContants.ADD%>');
	$("#<portlet:namespace/>fmDMSBN_ManHinhChinh").attr('action', '<%=DMSBN_ManHinhChinhURL.toString() %>');
	$("#<portlet:namespace/>fmDMSBN_ManHinhChinh").submit();
};
function soBanNganhIn(){
	console.log('soBanNganhIn');
	showPopupConfirm('<liferay-ui:message key="ban-co-muon-luu-thong-tin" />',['Yes','No'],function(index){
		if (index == 0)
		{
			$('#<portlet:namespace/>cmd').val('<%=QLKTCSDLDCContants.IN%>');
			$("#<portlet:namespace/>fmDMSBN_ManHinhChinh").attr('action', '<%=DMSBN_ManHinhChinhURL.toString() %>');
			$("#<portlet:namespace/>fmDMSBN_ManHinhChinh").attr('target', '_blank');
			$("#<portlet:namespace/>fmDMSBN_ManHinhChinh").submit();
		}
	});
};
</script>


